import * as THREE from "three";
import createCamera from "./camera";

const initRenderer = function (context) {
    let { scene, labelRenderer2D, labelRenderer3D } = context;
    let { camera, renderer } = createCamera(context);

    // 渲染
    const render = () => {
        renderer.render(scene, camera);
        labelRenderer2D.render(scene, camera); //渲染HTML标签对象 CSS2DObject 标签
        labelRenderer3D.render(scene, camera); //渲染HTML标签对象 CSS3DObject 标签

        //监听鼠标、键盘事件
        requestAnimationFrame(render);
    }
    return { camera, renderer, render };
}


export default initRenderer;